import request from '../utils/request.js'

export function createHOrder( o ) {
	return request(
		'horder/create',
		 {
			hHomestayId: o.hHomestayId,
			hUserOpenId: o.hUserOpenId,
			hOrderName: o.hOrderName,
			hUserName: o.hUserName,
			hUserPhone: o.hUserPhone,
			hUserIdno: o.hUserIdno,
			hOrderCheckinDate: o.hOrderCheckinDate,
			hOrderCheckoutDate: o.hOrderCheckoutDate,
			hOrderDays: o.hOrderDays,
			hSinglePrice: o.hSinglePrice,
			hTotalPrice: o.hTotalPrice,
			hDiscountPrice: '0',
			hFactPrice: o.hFactPrice,
			hScore: o.hScore
		}
	)
}

export function getHOrderByOrderId(orderId) {
	return request('horder/select/id/'+orderId)
}

export function updateHOrderStatusToSuccess(orderId) {
	return request('horder/status/'+ orderId +'/1')
}

export function updateOrderStatusToCancle(orderId) {
	return request('/horder/cancel/'+orderId)
}

export function getHOrderByOpenIdAndStatus(status) {
	const app = getApp()
	return request('horder/select/m/' + app.globalData.user.userOpenid + '/' + status)
}
